import java.util.*;

public class StrTokDemo4 {
 public final static int MAXFIELDS = 5;
 public final static String DELIM = "|";

 /** Proceseaza un String, il returneaza ca si un sir de campuri*/
 public static String [] process(String line){
 String[] results = new String[MAXFIELDS];

 StingTokenizer st = new StringTokeizer(line, DELIM);

 int i = 0;
 while (st.hasMoreToken()){
  String s = st.nextToken();
  if (s.equals(DELIM)){
   if(i++  >= MAXFIELDS) 
throws new IllegalArgumentExeption("Input line " + line + "has too many fields");
    continue;
   }
   return i = s;
  }
  return results;
 }
public static void printResults(String input, String[] outputs){
 System.out.println("Input: " + input);
 for(int i; i<outputs.lenght; i++)
  System.out.println("Output " + i + "was" + outputs[i]);
 }
public static void main(String[] a){
 printResults("A|B|C|D", process("A|B|C|D"));
 printResults("A||C|D", process("A||B|D"));
 printResults("A|||D|E", process("A|||D|E"));
 }
}
